<?php
namespace app\common\model;

use think\Model;
/**
 * 文章model
 */
class Art extends Model
{
    /**
     * @param $data
     * @return false|int
     * 添加分类
     */
    public function add($data) {
        
        return $this->save($data);
    }
    /**
     * 获得文章数据
     * @return [type] [description]
     */
    public function getArt(){
        return $this->alias('a')->join('cat w','a.cat_id=w.cat_id')->select();
    }
    /**
     * 根据id获得文章数据
     */
    public function getArtById($id){
        return $this->where('art_id',$id)->find();
    }
    /**
     * 获取留言
     */
    public function getMes(){
        return $this->alias('a')
        ->field('b.writer as username,b.create_time,b.content as mes')
        ->join('message b','a.art_id=b.art_id')
        ->paginate(5);
    }
}